<template>
  <!-- 订单统计 -->
  <div class="page-container">
    <page_breadcrumb :getKeyMethod="init_table_model" @change="change_table_model" pageOption />
    <ex_super_table_page v-bind="option" @selection-change="e => selection = e" ref="SuperTablePage">
    </ex_super_table_page>
  </div>
</template>

<script>
import superTablePageFunction from "@/mixin/super-table-page-function";
import page_table_model_manage from "@/mixin/page_table_model_manage";
import emitOnFunction from "@/mixin/emit-on-function";
let emitKey = "oms>purchase>operationsAnalysis>order_statistics";

export default {
  title: 'label_order_statistics',
  components: {
  },
  mixins: [
    superTablePageFunction,
    emitOnFunction(emitKey),
    page_table_model_manage,
  ],
  props: {
  },
  data() {
    return {
      option: {
        search: {
          model: [
            { label: "label_customer", key: "customerId", type: 'common_customer_choose' },
            {
              label: "label_supplier",
              key: "supplierId",
              type: "supplier_select_input"
            },
            {
              label: "label_warehouse_name",
              key: "warehouseId",
              type: "base_warehouse_select",
            },
          ],
        },
        actionExtra: [
          {
            label: "label_export",
            click: this.exportExcel,
            auth: 'oms_purchase_pay_export',
          },
        ],
        table: {
          url: "/oms-api/purchase/OmsPurchaseOrderPaymentRpc/selectPage.json",
          model: this.init_table_model(),
        },
      },
    }
  },
  methods: {
    option_table_model() {
      return [
        {
          type: "selection",
          clickToggle: true,
          keyGroup: "label_table_operate",
        },
        {
          key: "purchaser",
          label: "label_sku_buyer",
          "min-width": 130,
          "show-overflow-tooltip": true,
        },
        {
          key: "warehouseName",
          label: "label_warehouse_name",
          "min-width": 130,
          "show-overflow-tooltip": true,
          formatter: (r, c, v) => this.$formatNameCode(v, r.warehouseCode),
        },
        {
          key: "gmtCreate",
          label: "label_time",
          width: 170,
          render: (h, { row, column }) => {
            return (
              <div>
                <div>
                  {this.$t("label_create")}:{this.$dateFormat(row["gmtCreate"])}
                </div>
                <div>
                  {this.$t("label_update")}:{this.$dateFormat(row["gmtModify"])}
                </div>
              </div>
            );
          },
        },
        {
          type: "operate",
          width: 150,
          operate: [
            {
              label: "label_detail",
              click: row => {
                this.$router.push({
                  path: './order_detail', query: { id: row.id, }
                })
              }
            },
          ],
        },
      ];
    },
    exportExcel() {
      const searchParams = this.$refs.SuperTablePage.getSearchData()
      let idList = []
      if (this.selection) {
        idList = this.selection.map(item => item.id)
      }
      let params = { ...searchParams, idList }
      this.$functionCommon({
        url: "/oms-api/purchase/OmsPurchaseOrderPaymentRpc/exportExcel.json",
        data: params, type: 'form',
      })

    },
  }
};
</script>

<style lang="less" scoped></style>
